package org.neusoft.exception;


import org.neusoft.rsp.ApiResponse;
import org.springframework.web.bind.annotation.*;

/**
 * @AUTHOR 尹书岿
 * @DATE 2024/12/19 14:52
 * @DESCRIBE
 */
@RestControllerAdvice
public class GlobalExceptionHandler {
    @ExceptionHandler(AuthFailException.class)
    public ApiResponse<String> handleAuthFailException(AuthFailException e) {
        return ApiResponse.error(e.getCode(), e.getMessage());
    }

    @ExceptionHandler(UserExistException.class)
    public ApiResponse<String> handleUserExistException(UserExistException e) {
        return ApiResponse.error(e.getCode(), e.getMessage());
    }

    @ExceptionHandler(Exception.class)
    public ApiResponse<String> handleException(Exception e) {
        return ApiResponse.error(500,e.getMessage());
    }
}
